<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>show (TripsController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File trips_controller.rb, line 40</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show</span>
        <span class="ruby-ivar">@title</span> = <span class="ruby-value str">'Viajes de '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">' '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">lastname</span> 
    <span class="ruby-ivar">@trip</span> = <span class="ruby-constant">Trip</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
        <span class="ruby-ivar">@owner</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">find_by_id</span>(<span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">user_id</span>)
        <span class="ruby-ivar">@all_itineraries</span> = <span class="ruby-constant">Trip</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>]).<span class="ruby-identifier">itinerary</span>
        <span class="ruby-ivar">@user_invited</span> = <span class="ruby-constant">Trip</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>]).<span class="ruby-identifier">user</span>
        <span class="ruby-ivar">@itineraries</span> = <span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">itinerary</span>
        <span class="ruby-ivar">@friend_uninvited</span> = <span class="ruby-identifier">available_friends_for_trip</span>(<span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">id</span>)
        <span class="ruby-ivar">@body_tag</span> = <span class="ruby-value str">'onload=&quot;initMapTrip()&quot; id=&quot;public&quot;'</span>
        <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">tri_shared</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">or</span> (<span class="ruby-identifier">is_owner</span>(<span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">user_id</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">tri_shared</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)
                <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
                  <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># show.html.erb</span>
                  <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@trip</span>.<span class="ruby-identifier">tri_status</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
                        <span class="ruby-identifier">format</span>.<span class="ruby-identifier">pdf</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:format=</span><span class="ruby-operator">&gt;</span><span class="ruby-keyword kw">false</span>}
                  <span class="ruby-keyword kw">end</span>
                  <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@trip</span> }
                <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">else</span>
                <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'No tiene los suficientes provilegios para ver este viaje'</span>
                <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:controller</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'users'</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;home&quot;</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">id</span>
        <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">RecordNotFound</span>
                        <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:controller</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'users'</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;home&quot;</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">id</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>